<?php
include_once("common/init.php");
check_loginuser();
$goodsid = !empty($_POST['goodsid']) ? intval($_POST['goodsid']) : '0';
$sums = !empty($_POST['count']) ? intval($_POST['count']) : '1';
if($_REQUEST["a"]=="check_count"){
	$info = db_get_row("select * from goods where id=".$goodsid);
	if($info['amount']>$sums){
		db_query("update cart set sums=".$sums."+1 where goodsid=".$goodsid." and userid=".$_SESSION["id"]);
		echo "1";
	}
}
if($_REQUEST["a"]=="ajaxBuyCount"){
	if($sums>1){
		db_query("update cart set sums=".$sums."-1 where goodsid=".$goodsid." and userid=".$_SESSION["id"]);
		echo "ok";
	}
}
?>